package com.deyuanyun.pic.ctrl.controller.vo.exinsp;

import com.deyuanyun.pic.common.util.format.DateFormat;
import com.deyuanyun.pic.ctrl.domain.ExinspDrainage;
import com.deyuanyun.pic.ctrl.enumeration.AbnormalEnum;
import com.deyuanyun.pic.ctrl.enumeration.InterferenceTypeEnum;
import com.deyuanyun.pic.pipe.controller.vo.BaseVOUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

import java.math.BigDecimal;

/**
 * 排流装置检测记录表
 */
public class ExinspDrainageVO extends ExinspBaseVO<ExinspDrainage> {

    // 所属管道
    private String pipeLineName;
    // 设备编号(自定义编号)
    private String customNumber;
    // 测试桩编号
    private String testStationNum;
    // 干扰类型（交流、直流、交直流）
    private String interferenceType;
    // 管地电位（mV）
    public Long pipeToSoilPotential;
    // 交流电压（V）
    private BigDecimal acInterferenceVoltage;
    // 最大排流电流（mA）
    private BigDecimal drainageMax;
    // 最小排流电流（mA）
    private BigDecimal drainageMin;
    // 平均排流电流（mA）
    private BigDecimal drainageAvg;
    // 开路电位（mV）
    public Long openCircuitPotential;
    // 接地电阻（Ω）
    private BigDecimal groundingResistance;
    // 异常记录
    private String faultRecord;
    // 是否有异常(YES、NO)
    private String abnormal;
    // 处理措施
    private String treatmentMeasures;
    // 检测日期
    private String detectiongDete;

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getCustomNumber() {
        return customNumber;
    }

    public void setCustomNumber(String customNumber) {
        this.customNumber = customNumber;
    }

    public String getTestStationNum() {
        return testStationNum;
    }

    public void setTestStationNum(String testStationNum) {
        this.testStationNum = testStationNum;
    }

    public String getInterferenceType() {
        return interferenceType;
    }

    public void setInterferenceType(String interferenceType) {
        this.interferenceType = interferenceType;
    }

    public Long getPipeToSoilPotential() {
        return pipeToSoilPotential;
    }

    public void setPipeToSoilPotential(Long pipeToSoilPotential) {
        this.pipeToSoilPotential = pipeToSoilPotential;
    }

    public BigDecimal getAcInterferenceVoltage() {
        return acInterferenceVoltage;
    }

    public void setAcInterferenceVoltage(BigDecimal acInterferenceVoltage) {
        this.acInterferenceVoltage = acInterferenceVoltage;
    }

    public BigDecimal getDrainageMax() {
        return drainageMax;
    }

    public void setDrainageMax(BigDecimal drainageMax) {
        this.drainageMax = drainageMax;
    }

    public BigDecimal getDrainageMin() {
        return drainageMin;
    }

    public void setDrainageMin(BigDecimal drainageMin) {
        this.drainageMin = drainageMin;
    }

    public BigDecimal getDrainageAvg() {
        return drainageAvg;
    }

    public void setDrainageAvg(BigDecimal drainageAvg) {
        this.drainageAvg = drainageAvg;
    }

    public Long getOpenCircuitPotential() {
        return openCircuitPotential;
    }

    public void setOpenCircuitPotential(Long openCircuitPotential) {
        this.openCircuitPotential = openCircuitPotential;
    }

    public BigDecimal getGroundingResistance() {
        return groundingResistance;
    }

    public void setGroundingResistance(BigDecimal groundingResistance) {
        this.groundingResistance = groundingResistance;
    }

    public String getFaultRecord() {
        return faultRecord;
    }

    public void setFaultRecord(String faultRecord) {
        this.faultRecord = faultRecord;
    }

    public String getAbnormal() {
        return abnormal;
    }

    public void setAbnormal(String abnormal) {
        this.abnormal = abnormal;
    }

    public String getTreatmentMeasures() {
        return treatmentMeasures;
    }

    public void setTreatmentMeasures(String treatmentMeasures) {
        treatmentMeasures = treatmentMeasures;
    }

    public String getDetectiongDete() {
        return detectiongDete;
    }

    public void setDetectiongDete(String detectiongDete) {
        this.detectiongDete = detectiongDete;
    }

    public void fromDomain(ExinspDrainage domain) {

        // 管道名称
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 设备编号(自定义编号)
        this.customNumber = domain.getCustomNumber();
        // 测试桩编号
        this.testStationNum = domain.getTestStationId();
        // 干扰类型（交流、直流、交直流）
        this.interferenceType = InterferenceTypeEnum.getLabel(domain.getInterferenceType());
        // 管地电位（mV）
        this.pipeToSoilPotential = domain.getPipeToSoilPotential();
        // 交流电压（V）
        this.acInterferenceVoltage = domain.getAcInterferenceVoltage();
        // 最大排流电流（mA）
        this.drainageMax = domain.getDrainageMax();
        // 最小排流电流（mA）
        this.drainageMin = domain.getDrainageMin();
        // 平均排流电流（mA）
        this.drainageAvg = domain.getDrainageAvg();
        // 开路电位（mV）
        this.openCircuitPotential = domain.getOpenCircuitPotential();
        // 接地电阻（Ω）
        this.groundingResistance = domain.getGroundingResistance();
        // 异常记录
        this.faultRecord = domain.getFaultRecord();
        // 是否有异常(YES、NO)
        this.abnormal = AbnormalEnum.getLabel(domain.getAbnormal());
        // 处理措施
        this.treatmentMeasures = domain.getUpdateRemark();;
        // 检测日期
        this.detectiongDete = DateFormat.format(domain.getDetectiongDete());

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordTime(), domain.getRemarks());
    }

    public Page<ExinspDrainageVO> fromDomainList(Page<ExinspDrainage> domainList) {

        Page<ExinspDrainageVO> list = new Page<ExinspDrainageVO>();
        for (ExinspDrainage exinspDrainage : domainList) {
            ExinspDrainageVO exinspDrainageVO = new ExinspDrainageVO();
            exinspDrainageVO.fromDomain(exinspDrainage);
            list.add(exinspDrainageVO);
        }
        BaseVOUtil.converterPage(domainList, list);
        return list;
    }
}

